// 题解： https://blog.csdn.net/qq_61051045/article/details/119928876?spm=1001.2014.3001.5501


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int qaq[200010][55];
int val[200010];
int col[200010];
long long ans;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    for(int i = 1;i <= a;i ++) {
        cin>>col[i]>>val[i];
        qaq[i][col[i]] ++;
        for (int j = 0; j < b; ++j) {
            qaq[i][j] += qaq[i - 1][j];   //前缀和
        }
    }
    int p = 0;                            //记录上次在哪里更新的答案
    for (int k = 1; k <= a; ++k) {
        if(val[k] <= c) {
            for (int i = 0; i < b ; ++i) {
                ans += (qaq[k - 1][i] - qaq[p][i]) * (qaq[a][i] - qaq[k][i]);    //乘法原理统计答案
            }
            ans += qaq[a][col[k]] - qaq[p][col[k]] - 1;       //计算住在这个点下对答案的贡献，-1是因为要把自己这个点减去
            p = k;                //P点更新
        }
    }
    cout<<ans;
    return 0;
}